#ifndef NETPACKET_H
#define NETPACKET_H

#include "main.h"
#include "globals.h"

#define NETPACKET_SIZE					3078
#define NETPACKET_RESERV				512

#define E_NETWORK_MODBUS_UP				0x01
#define E_NETWORK_MODBUS_DOWN			0x02
#define E_NETWORK_MODBUS_SEND_END		0x08
#define E_NETWORK_MODBUS_SEND			0x04

#define E_NET_STATE_IDLE				0x00
#define E_NET_STATE_TUNE_CONNECT_UP		0x01
#define E_NET_STATE_TUNE_CONNECT_DOWN	0x02
#define E_NET_STATE_SEND_PACKET			0x04
#define E_NET_STATE_CONNECT_DOWN		0x08
#define E_NET_STATE_CONNECT_UP			0x10
#define E_NET_STATE_CONNECT_ERR			0x20
#define E_NET_STATE_INIT				0x80

typedef struct sNetStruct
{
	char netPacket[NETPACKET_SIZE];
	uint8_t type_connection;
	uint16_t couneterPacket;
	uint8_t tune_action;
	uint8_t connect_state;
}sNetStruct;

extern sNetStruct netStruct;

eReturn NetworkModbusAction(uint8_t type);
eReturn NetworkModbusCheckBuffer(void);
void NetWorkTask(void *pvParameters);

#endif
